<?php

class ClockTimeModel extends CFormModel
{

    public $weekIndex   = 0;
    public $managerId   = 0;
    public $userId      = 0;
    private $daysInWeek = NULL;

    public function rules()
    {
        return array(
            array('weekIndex, userId, managerId', 'required'),
            array('weekIndex, userId, managerId', 'numerical', 'integerOnly' => true),
        );
    }

    public function getDaysInWeek()
    {
        if ($this->daysInWeek == NULL)
        {
            $startDate = date("Y-m-d", strtotime("last Monday"));
            $data      = array();
            for ($i = 0; $i < 7; $i++)
            {
                $data[] = date("l M-d", strtotime("{$startDate} + " . ($this->weekIndex * 7 + $i) . " days"));
            }
            $this->daysInWeek = $data;
        }
        return $this->daysInWeek;
    }

}
